﻿using System.Collections.Generic;
using Xenta.Api;
using Xenta.Entities;
using Xenta.Security;
using Xenta.Utils;

namespace Xenta.Operations
{
    #region __General__

    /// <summary>
    /// Creates a payment attribute.
    /// </summary>
    public class CreatePaymentAttribute : CreateGenericAttribute<PaymentAttributeEntity>
    {
    }

    /// <summary>
    /// Creates a payment attribute.
    /// </summary>
    public class UpdatePaymentAttribute : UpdateGenericAttribute<PaymentAttributeEntity>
    {
    }

    /// <summary>
    /// Sets a payment attribute.
    /// </summary>
    public class SetPaymentAttribute : SetGenericAttribute<PaymentAttributeEntity>,
        ISecuredOperation, IApiOperation
    {
        #region Properties

        /// <summary>
        /// Gets the collection of security policies.
        /// </summary>
        public IEnumerable<SecurityPolicy> SecurityPolicies
        {
            get
            {
                yield return new SecurityPolicy()
                    .IsAuthenticated()
                    .HasPermission("SALES");
            }
        }

        #endregion
    }

    /// <summary>
    /// Deletes the payment attribute.
    /// </summary>
    public class DeletePaymentAttribute : DeleteGenericAttribute<PaymentAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the payment attribute by identifier.
    /// </summary>
    public class GetPaymentAttribute : GetGenericAttribute<PaymentAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the payment attribute by the key.
    /// </summary>
    public class GetPaymentAttributeByKey : GetGenericAttributeByKey<PaymentAttributeEntity>
    {
    }

    /// <summary>
    /// Gets the payment attribute value by key.
    /// </summary>
    public class GetPaymentAttributeValueByKey : GetGenericAttributeValueByKey<PaymentAttributeEntity>,
        IApiOperation
    {
    }

    #endregion

    #region __Bulk__

    /// <summary>
    /// Updates the payment attributes from dictionary.
    /// </summary>
    public class BulkUpdatePaymentAttributes : BulkUpdateGenericAttributes<PaymentAttributeEntity>,
        ISecuredOperation, IApiOperation
    {
        #region Properties

        /// <summary>
        /// Gets the collection of security policies.
        /// </summary>
        public IEnumerable<SecurityPolicy> SecurityPolicies
        {
            get
            {
                yield return new SecurityPolicy()
                    .IsAuthenticated()
                    .HasPermission("SALES");
            }
        }

        #endregion
    }

    #endregion
}
